// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
    public static void main(String[] args) {
        // Press Alt+Enter with your caret at the highlighted text to see how
        // IntelliJ IDEA suggests fixing it.
        double sum =0,a=1,i=1;
        do{
            sum = sum+a;
            i++;
            a=(1.0/i)*a;
        }
        while(i<=20);
        System.out.println("使用do-while循环计算的sum="+sum);
        for(sum = 0,i =1 ,a=1;i<=20;i++){
            a= a*(1.0/i);
            sum = sum+a;
        }
        System.out.println("使用for循环计算的sum="+sum);


    }
}